static void
pack_border (GtkCssShorthandProperty *shorthand,
GValue *value,
- GtkStyleProperties *props,
- GtkStateFlags state)
+ GtkStyleQueryFunc query_func,
+ gpointer query_data)
{
GtkCssStyleProperty *prop;
GtkBorder border;
const GValue *v;
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
- v = _gtk_style_properties_peek_property (props, prop, state);
+ v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
border.top = g_value_get_int (v);
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 1);
- v = _gtk_style_properties_peek_property (props, prop, state);
+ v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
border.right = g_value_get_int (v);
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 2);
- v = _gtk_style_properties_peek_property (props, prop, state);
+ v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
border.bottom = g_value_get_int (v);
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 3);
- v = _gtk_style_properties_peek_property (props, prop, state);
+ v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
border.left = g_value_get_int (v);
static void
pack_border_radius (GtkCssShorthandProperty *shorthand,
GValue *value,
- GtkStyleProperties *props,
- GtkStateFlags state)
+ GtkStyleQueryFunc query_func,
+ gpointer query_data)
{
GtkCssBorderCornerRadius *top_left;
+ GtkCssStyleProperty *prop;
+ const GValue *v;
- /* NB: We are an int property, so we have to resolve to an int here.
- * So we just resolve to an int. We pick one and stick to it.
- * Lesson learned: Don't query border-radius shorthand, query the
- * real properties instead. */
- gtk_style_properties_get (props,
- state,
- "border-top-left-radius", &top_left,
- NULL);
-
- if (top_left)
- g_value_set_int (value, top_left->horizontal);
-
- g_free (top_left);
+ prop = GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("border-top-left-radius"));
+ v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
+ if (v)
+ {
+ top_left = g_value_get_boxed (v);
+ if (top_left)
+ g_value_set_int (value, top_left->horizontal);
+ }
}
static void
static void
pack_font_description (GtkCssShorthandProperty *shorthand,
GValue *value,
- GtkStyleProperties *props,
- GtkStateFlags state)
+ GtkStyleQueryFunc query_func,
+ gpointer query_data)
{
PangoFontDescription *description;
- char **families;
- PangoStyle style;
- PangoVariant variant;
- PangoWeight weight;
- double size;
-
- gtk_style_properties_get (props,
- state,
- "font-family", &families,
- "font-style", &style,
- "font-variant", &variant,
- "font-weight", &weight,
- "font-size", &size,
- NULL);
+ const GValue *v;
description = pango_font_description_new ();
- /* xxx: Can we set all the families here somehow? */
- if (families)
- pango_font_description_set_family (description, families[0]);
- pango_font_description_set_size (description, round (size * PANGO_SCALE));
- pango_font_description_set_style (description, style);
- pango_font_description_set_variant (description, variant);
- pango_font_description_set_weight (description, weight);
- g_strfreev (families);
+ v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-family"))), query_data);
+ if (v)
+ {
+ const char **families = g_value_get_boxed (v);
+ /* xxx: Can we set all the families here somehow? */
+ if (families)
+ pango_font_description_set_family (description, families[0]);
+ }
+
+ v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-size"))), query_data);
+ if (v)
+ pango_font_description_set_size (description, round (g_value_get_double (v) * PANGO_SCALE));
+
+ v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-style"))), query_data);
+ if (v)
+ pango_font_description_set_style (description, g_value_get_enum (v));
+
+ v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-variant"))), query_data);
+ if (v)
+ pango_font_description_set_variant (description, g_value_get_enum (v));
+
+ v = (* query_func) (_gtk_css_style_property_get_id (GTK_CSS_STYLE_PROPERTY (_gtk_style_property_lookup ("font-weight"))), query_data);
+ if (v)
+ pango_font_description_set_weight (description, g_value_get_enum (v));
g_value_take_boxed (value, description);
}
static void
pack_first_element (GtkCssShorthandProperty *shorthand,
GValue *value,
- GtkStyleProperties *props,
- GtkStateFlags state)
+ GtkStyleQueryFunc query_func,
+ gpointer query_data)
{
GtkCssStyleProperty *prop;
const GValue *v;
for (i = 0; i < _gtk_css_shorthand_property_get_n_subproperties (shorthand); i++)
{
prop = _gtk_css_shorthand_property_get_subproperty (shorthand, 0);
- v = _gtk_style_properties_peek_property (props, prop, state);
+ v = (* query_func) (_gtk_css_style_property_get_id (prop), query_data);
if (v)
{
g_value_copy (v, value);
/**
* _gtk_style_property_query:
* @property: the property
- * @props: The properties to query
- * @state: The state to query
* @value: (out): an uninitialized #GValue to be filled with the
* contents of the lookup
+ * @query_func: The function to use to query properties
+ * @query_data: The data to pass to @query_func
*
* This function is called by gtk_style_properties_get() and in
* turn gtk_style_context_get() and similar functions to get the
* value to return to code using old APIs.
**/
void
-_gtk_style_property_query (GtkStyleProperty *property,
- GtkStyleProperties *props,
- GtkStateFlags state,
- GValue *value)
+_gtk_style_property_query (GtkStyleProperty *property,
+ GValue *value,
+ GtkStyleQueryFunc query_func,
+ gpointer query_data)
{
GtkStylePropertyClass *klass;
- g_return_if_fail (property != NULL);
- g_return_if_fail (GTK_IS_STYLE_PROPERTIES (props));
+ g_return_if_fail (GTK_IS_STYLE_PROPERTY (property));
g_return_if_fail (value != NULL);
+ g_return_if_fail (query_func != NULL);
klass = GTK_STYLE_PROPERTY_GET_CLASS (property);
g_value_init (value, property->value_type);
- klass->query (property, props, state, value);
+ klass->query (property, value, query_func, query_data);
}
void